package com.safeluck.scannerqcr.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.safeluck.scannerqcr.R;
import com.safeluck.scannerqcr.adapter.MoreAdapter;
import com.safeluck.scannerqcr.bean.Article;

import java.util.ArrayList;
import java.util.List;

/**
 * ScannerQCR
 * Created by lzw on 2017/11/28. 17:18:02
 * 邮箱：632393724@qq.com
 * All Rights Saved! Chongqing AnYun Tech co. LTD
 */

public class WechatThirdTabFragment extends BaseMainFragment{

    private RecyclerView mRecyclerView;
    private Toolbar mToobar;
    private MoreAdapter moreAdapter;
    private List<Article> datas = new ArrayList<>();
    private String[] mTitles;
    private String[] contents;
    private String[] mCategory;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.wechat_fragment_third_tab,container,false);
        initView(view);
        return view;
    }

    public static WechatThirdTabFragment newInstance(){
        Bundle bundle = new Bundle();
        WechatThirdTabFragment wechatFirstTabFragment = new WechatThirdTabFragment();
        wechatFirstTabFragment.setArguments(bundle);
        return wechatFirstTabFragment;
    }
    private void initView(View view) {
        mToobar = view.findViewById(R.id.toolbar);
        mRecyclerView = view.findViewById(R.id.recy);
        mToobar.setTitle("More");

        mRecyclerView.setLayoutManager(new LinearLayoutManager(_mActivity));
        mRecyclerView.setHasFixedSize(true);
        mTitles = getResources().getStringArray(R.array.array_title);
        contents = getResources().getStringArray(R.array.array_content);
        mCategory = getResources().getStringArray(R.array.array_category);

        moreAdapter = new MoreAdapter(_mActivity);
        mRecyclerView.setAdapter(moreAdapter);
        datas = initData();
        moreAdapter.setDatas(datas);
    }

    private List<Article> initData() {
        List<Article> tms = new ArrayList<>();
        for (int i=0; i<3; i++){
            Article mArticle = new Article(mCategory[i],mTitles[i],contents[i]);
            tms.add(mArticle);
        }
        return tms;

    }
}
